//
//  SubmitMyListViewController.m
//  DA_V
//
//  Created by 中亿世联前台 on 15/4/29.
//  Copyright (c) 2015年 zhouhai. All rights reserved.
//

#import "SubmitMyListViewController.h"
#import "ConfirmShopingListViewController.h"
#import "ShoppingListAddressView.h"
#import "ShoppingImageView.h"
#import "ShoppingImageScrollView.h"
#import "PaymentValuatioTableViewCell.h"
#import "UIViewAdditions.h"
#import "AllPraceViw.h"
#import "InterFace.h"
#import "InformationButton.h"
#import "CarModel.h"
#import "CityModel.h"
#import "AddressView.h"
#import "InfoViewController.h"

@interface SubmitMyListViewController ()
@property (nonatomic, strong) AddressView  *addressView;
@property (nonatomic, strong) ShoppingImageScrollView *shoppingScrollView;
@property (nonatomic, strong) UIScrollView *scrollView;
@end

@implementation SubmitMyListViewController

- (instancetype)init{
    self = [super init];
    if (self) {
        self.carModelArray = [NSMutableArray array];//此数组主要来接收提交订单页传过来的购物车Model
    }
    return self;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self.navigationItem setHidesBackButton:YES];
    [self createBackButton];
    self.scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
    self.scrollView.backgroundColor = LineColor;
    //    if (SCREEN_HEIGHT < 568) {
    self.scrollView.contentSize = CGSizeMake(SCREEN_WIDTH, SCREEN_HEIGHT*1.2);
    //    }
    [self.view addSubview:self.scrollView];
    [self creareAddressView];
}
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.navigationController.navigationBarHidden=NO;
}

#pragma -mmark 创建返回按钮
-(void)createBackButton{
    UIView *qview = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 40)];
    
    UIButton *backBut = [UIButton buttonWithType:UIButtonTypeCustom];
    backBut.frame = CGRectMake(-25, -2, 85, 44);
    
    [backBut setImage:[UIImage imageNamed:@"fanhui"] forState:UIControlStateNormal];
    [backBut addTarget:self action:@selector(backClick23) forControlEvents:UIControlEventTouchUpInside];
    [qview addSubview:backBut];
    
    UILabel *title = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/2-110, 5, 200, 30)];
    title.textAlignment = NSTextAlignmentCenter;
    title.font = [UIFont fontWithName:@"Helvetica-Bold" size:17];
    title.text = @"订单已提交";
    title.textColor = [UIColor whiteColor];
    [qview addSubview:title];
    self.navigationItem.titleView = qview;
    
    InformationButton *infonmationBut = [[InformationButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH-50, 0, 44, 44)];
    infonmationBut.informationNum.text = @"20";
    [infonmationBut addTarget:self action:@selector(goINfoVC) forControlEvents:UIControlEventTouchUpInside];
    [infonmationBut setImage:[UIImage imageNamed:@"查看库存_03"] forState:UIControlStateNormal];
    [qview addSubview:infonmationBut];
}
- (void)goINfoVC{
    
    InfoViewController *infomation =[[InfoViewController alloc] init];
    [self.navigationController pushViewController:infomation animated:YES];
}
#pragma -mark 返回按钮事件
- (void)backClick23{
 [[NSNotificationCenter defaultCenter] postNotificationName:@"CarNumberChange"object:nil];
    [self.navigationController popToRootViewControllerAnimated:YES];
}


#pragma -mark 添加地址View
- (void)creareAddressView{
    
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 350)];
    
//    @property (weak, nonatomic) IBOutlet UILabel *listNum;  //订单号
//    
//    @property (weak, nonatomic) IBOutlet UILabel *listTime; //下单时间
//    
//    @property (weak, nonatomic) IBOutlet UITextField *name; //姓名
//    
//    
//    @property (weak, nonatomic) IBOutlet UITextField *phoneNUme; //电话号码
//    
//    
//    @property (weak, nonatomic) IBOutlet UITextView *address; //地址

    
//    @property(nonatomic, strong) CarModel *carModel;            //用来接收订单也传过来的model;
//    @property(nonatomic, strong) NSMutableArray *carModelArray; //用来接收交传过来的model数组;
//    @property(nonatomic, copy)   NSString *masterOrderId;       //用来接收交传过来的订单号
//    @property(nonatomic, copy)   NSString *xiaDanTime;          //用来接收交传过来的下单时间
//    @property(nonatomic, copy)   NSString *address;             //用来接收交传过来的地址
    
    self.addressView = [[[NSBundle mainBundle] loadNibNamed:@"AddressXib" owner:self options:nil] objectAtIndex:0];
    _addressView.listNum.text = [NSString stringWithFormat:@"订单号:%@",self.masterOrderId];
    _addressView.listTime.text = [NSString stringWithFormat:@"下单时间:%@",self.xiaDanTime];
    self.addressView.name.text = self.name;//[NSString stringWithFormat:@"下单人:%@",self.name];//@"下单人:吴彦祖";
    self.addressView.phoneNUme.text = self.phoneNumber;//[NSString stringWithFormat:@"电    话:%@",self.phoneNumber];
    _addressView.address.text = self.address;
    _addressView.frame = CGRectMake(0, 0, SCREEN_WIDTH, 170);
    _addressView.userInteractionEnabled = NO;
    [view addSubview:_addressView];
    
    
    
//    //创建滑动商品图片
//    CGRect rect = CGRectMake(0, self.addressView.bottom , SCREEN_WIDTH, (SCREEN_WIDTH-50) / 3.0+40);
//    self.shoppingScrollView = [ShoppingImageScrollView  soppingImageScrollViewWithFrame:rect data:nil];
//    self.shoppingScrollView.backgroundColor = [UIColor whiteColor];
//    self.shoppingScrollView.contentSize = CGSizeMake(SCREEN_WIDTH*2, 120);
//    [view addSubview:self.shoppingScrollView];
//    
//    UIView *lineview2 = [[UIView alloc]initWithFrame:CGRectMake(0, self.shoppingScrollView.bottom, SCREEN_WIDTH, 10)];
//    lineview2.backgroundColor = [UIColor whiteColor];
//    [view addSubview:lineview2];
//    
//    //线条
//    UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(10, lineview2.bottom-5, SCREEN_WIDTH-20, 1)];
//    lineView.backgroundColor = LineColor;
//    [view addSubview:lineView];

    //创建滑动商品图片
    CGRect rect = CGRectMake(0, self.addressView.bottom , SCREEN_WIDTH, (SCREEN_WIDTH-50) / 3.0+40);
    self.shoppingScrollView = [ShoppingImageScrollView  soppingImageScrollViewWithFrame:rect data:self.carModelArray];
    self.shoppingScrollView.backgroundColor = [UIColor whiteColor];
    self.shoppingScrollView.contentSize = CGSizeMake(SCREEN_WIDTH*2, 120);
    [view addSubview:self.shoppingScrollView];
    
    UIView *lineview2 = [[UIView alloc]initWithFrame:CGRectMake(0, self.shoppingScrollView.bottom, SCREEN_WIDTH, 10)];
    lineview2.backgroundColor = [UIColor whiteColor];
    [view addSubview:lineview2];
    
    //线条
    UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(10, lineview2.bottom-5, SCREEN_WIDTH-20, 1)];
    lineView.backgroundColor = LineColor;
    [view addSubview:lineView];
    
    AllPraceViw *allPraceView = (AllPraceViw *)[[[NSBundle mainBundle] loadNibNamed:@"Shopping_Cart_Xib" owner:self options:nil] objectAtIndex:8];
//    @property (weak, nonatomic) IBOutlet UILabel *merchantPrace;//微商金额
//    
//    @property (weak, nonatomic) IBOutlet UILabel *allPrace;//总金额
    
    allPraceView.merchantPrace.text = [NSString stringWithFormat:@"¥%.1f",self.carModel.DiscountPriceAmount.floatValue];
    allPraceView.allPrace.text = [NSString stringWithFormat:@"¥%.1f",self.carModel.MarketPriceAmount.floatValue];
    allPraceView.frame = CGRectMake(0, lineView.bottom, SCREEN_WIDTH, 50);
    [view addSubview:allPraceView];
    
    [self.scrollView addSubview:view];
    
    
    
    UIImageView *tijaoImage = [[UIImageView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH/3.0-30, view.bottom+20, 20, 20)];
    
    tijaoImage.image = [UIImage imageNamed:@"订单完成_03"];
    [self.scrollView addSubview:tijaoImage];
    
    UILabel *title = [[UILabel alloc] initWithFrame:CGRectMake(tijaoImage.right+5, view.bottom+10, SCREEN_WIDTH/3.0-40+50, 40)];
    
    title.text = @"您的订单已提交";
    title.font = [UIFont fontWithName:nil size:15];
    [self.scrollView addSubview:title];
    
    UIButton *backBut = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH/3.0-30, tijaoImage.bottom+10, SCREEN_WIDTH/3.0+50, 40)];
    [backBut addTarget:self action:@selector(backClick) forControlEvents:UIControlEventTouchUpInside];
    [backBut setBackgroundImage:[UIImage imageNamed:@"订单完成_07"] forState:UIControlStateNormal];
    [self.scrollView addSubview:backBut];
    
}
-(void)backClick{
    [self.navigationController popToRootViewControllerAnimated:YES];
}

@end
